#ifndef GENERAL_H
#define GENERAL_H

#include "constants.h"
#include <cmath>

using namespace std;

// position of a node
struct Position
{
	int x;
	int y;

	static bool isNeighbor(int x1, int y1, int x2, int y2)
	{
		double dis = sqrt((double)(x2 - x1) * (x2 - x1) + (double)(y2 - y1) * (y2 - y1));
		return dis <= COMM_RANGE;
	}

	bool isNeighbor(int x1, int y1)
	{
		double dis = sqrt((double)(x - x1) * (x - x1) + (double)(y - y1) * (y - y1));
		return dis <= COMM_RANGE;
	}

	bool isNeighbor(Position p2)
	{
		return isNeighbor(p2.x, p2.y);
	}

	void setXY(int x1, int y1)
	{
		x = x1;
		y = y1;
	}
};

struct Traffic
{
	int time_slot;
	int sender_id;
	int receiver_id;
	int pkt_number;

	Traffic(int time, int sender, int receiver, int pkt)
	{
		time_slot = time;
		sender_id = sender;
		receiver_id = receiver;
		pkt_number = pkt;
	}
};

#endif